package com.eric.server.packet;

import io.netty.buffer.ByteBuf;
import io.netty.buffer.Unpooled;
import io.netty.channel.ChannelHandlerContext;
import io.netty.handler.codec.MessageToByteEncoder;

import java.io.ByteArrayOutputStream;

public class PacketEncoder extends MessageToByteEncoder<Packet> {


	@Override
    protected void encode(ChannelHandlerContext ctx, Packet msg, ByteBuf out)
			throws Exception {
		try {
			_encode(ctx, msg, out);
		}catch(Exception e) {
			e.printStackTrace();
		}
	}

	private void _encode(ChannelHandlerContext ctx, Packet msg, ByteBuf out) throws Exception {
		msg.writeToBuff(out);
	}

}